package z.explorer.storage;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import z.explorer.Main;
import z.explorer.core.storage.TableMetaData;
import z.explorer.core.storage.dao.TableMetaDataDAO;

import z.explorer.core.task.dao.TaskDAO;
import z.explorer.task.TaskViewer;
import z.explorer.ui.common.Handler;
import z.explorer.ui.common.ZTablePanel;
import z.explorer.ui.component.walker.ZWalker;

public class TableViewer implements Handler  {
	private static Log log = LogFactory.getLog(TaskViewer.class);
	@Override
	public void handle() {
		// TODO Auto-generated method stub
		TableMetaDataDAO tableMetaDataDao = (TableMetaDataDAO) Main.context.getBean("tableMetaDataDAO");
		log.info("start to search metadata for table");
		List<TableMetaData> list = tableMetaDataDao.searchAll();
		log.info("end in searching metadata for table");
		ZTablePanel ztp = new ZTablePanel(list);
		ZWalker walker = (ZWalker) Main.context.getBean("zWalker");
		walker.addPanel("tableViewer", ztp);
	}
	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return "loading the metadata for table ...";
	}

}
